@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row">
            <div class="col-md-12 col-md-offset-1">
                <div class="panel panel-default">
                    <div class="panel-heading">评论管理</div>
                    <div class="panel-body">
                        @if (count($errors) > 0)
                            <div class="alert alert-danger">
                                {!! implode('<br>', $errors->all()) !!}
                            </div>
                        @endif
                        <div class="table-responsive">
                            <table class="table table-bordered" style="table-layout:fixed">
                                <thead>
                                <tr>
                                    <th width="25%">Content</th>
                                    <th width="15%">User</th>
                                    <th width="20%">Page</th>
                                    <th width="20%">编辑</th>
                                    <th width="20%">删除</th>
                                </tr>
                                </thead>
                                @foreach ($comments as $comment)
                                    <tbody>
                                    <tr>
                                        <th style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">{{$comment->content}}</th>
                                        <th style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
                                            <a href="nav-link" href="#">{{$comment->nickname}}</a>
                                            {{$comment ->email}}
                                        </th>
                                        <th style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">{{$comment->hasOneArticle->title}}</th>
                                        <th style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
                                            <a href="{{ url('admin/comment/'.$comment->id.'/edit') }}"
                                               class="btn btn-success">编辑</a>
                                        </th>
                                        <th style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
                                            <form action="{{ url('admin/comment/'.$comment->id) }}" method="POST"
                                                  style="display: inline;">
                                                {{ method_field('DELETE') }}
                                                {{ csrf_field() }}
                                                <button type="submit" class="btn btn-danger">删除</button>
                                            </form>
                                        </th>
                                    </tr>
                                    </tbody>
                                @endforeach
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection